package org.wmq.shopmanager.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.wmq.commonutil.result.Result;
import org.wmq.shopmanager.service.SystemUserService;
import org.wmq.shopmodel.DTO.system.SystemUserQueryDTO;
import org.wmq.shopmodel.Entity.system.SystemUser;

@RestController
@RequestMapping("/admin/system/system-user")
@RequiredArgsConstructor
public class SystemUserController {
    private final SystemUserService systemUserService;

    @GetMapping("/page")
    public Result<IPage<SystemUser>> getSystemUserPageItem(@ModelAttribute SystemUserQueryDTO systemUserQueryDTO){
        return Result.success(this.systemUserService.getPageItem(systemUserQueryDTO));
    }

    @PostMapping
    public Result<Void> saveSystemUser(@RequestBody SystemUser systemUser){
        return this.systemUserService.saveSystemUser(systemUser);
    }
    @PutMapping
    public Result<Void> updateSystemUserById(@RequestBody SystemUser systemUser){
        return this.systemUserService.updateSystemUserById(systemUser);
    }
    @DeleteMapping("/{id}")
    public Result<Void> deleteSystemUserById(@PathVariable Long id){
        this.systemUserService.removeById(id);
        return Result.success();
    }

}
